package tests.user;

import java.awt.Color;

/**
 * Copyright 2007, 2008 Viera K. Proulx
 * This program is distributed under the terms of the 
 * GNU Lesser General Public License (LGPL)
 */

/*
    +--------------+
    | Sampler      |
    +--------------+
    | String title | 
    | int    time  |
    +--------------+  
 */  

/**
 * A class to test visibility modifier access,
 * the handling of colors, and more...
 * 
 * @author Viera K. Proulx
 * @since 30 May 2007
 */
public class Sampler{

  /** the title field -- protected */
  protected String title;
  /** the length field -- private */
  private int length;
  
  /** the counter field -- static */
  public static int counter = 0;
  
  /** the color -- as defined in the java.awt */
  public Color javaColor;

  /**
   * The standard constructor
   * @param title the title of the sampler
   * @param length the length of the sampler
   * @param javaColor the Color field
   */
  public Sampler(String title, int length, Color javaColor){
    this.title = title;
    this.length = length;
    this.javaColor = javaColor;
    counter = counter + 1;
  }
  

  
  /**
   * A method used to test protected method invocation
   * and a return value other than boolean
   * combined with the use of static variables
   * 
   * @param that a sampler to compare with
   * @return the shorter song between this and that
   */
  @SuppressWarnings("unused")
  private Sampler shorter(Sampler that){
    if (this.length < Sampler.counter)
      return this;
    else
      return that;
  }
  
  
  /**
   * An inner class to test the access to its data and methods
   * 
   * @author Viera K. Proulx
   * @since 4 November 2007
   */
  class Insider{
    String data;
    int number;
    
    Insider(String data, int number){
      this.data = data;
      this.number = number;
    }
    
    String combine(){
      return this.data + ": " + this.number;
    }
    
    int count(){
      return this.number + this.data.length();
    }
  }
}         

/**
 * A package-protected class to test the access to its data and methods
 * 
 * @author Viera K. Proulx
 * @since 4 November 2007
 */
class Outsider{
  String odata;
  int onumber;
  
  Outsider(String odata, int onumber){
    this.odata = odata;
    this.onumber = onumber;
  }
  
  String outCombine(){
    return this.odata + ": " + this.onumber;
  }
  
  int outCount(){
    return this.onumber + this.odata.length();
  }
}



